package com.coderman.common.starter.controller;

import com.alibaba.fastjson.JSON;
import com.coderman.common.starter.entity.FeeCodeConfigEntity;
import com.coderman.common.starter.logparam.annotations.RequestLogic;
import com.coderman.common.starter.nacos.datajson.service.DataJsonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description:
 * date: 2020/9/30 5:53 下午
 *
 * @author fanchunshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@RestController
public class ConfigController {
    @Autowired
    private DataJsonService dataJsonService;

    @GetMapping(value = "/getconfiglist")
    public String getConfig(){
        List list = dataJsonService.getDataConfigList(FeeCodeConfigEntity.class);
        return JSON.toJSONString(list);
    }

    @GetMapping(value = "/getconfig")
    @RequestLogic(logInParam = true,logOutParam = true,exeTime = true)
    public String getConfig(@RequestParam(value = "feeCode") String feeCode,
                            @RequestParam(value = "id") Long id){
        FeeCodeConfigEntity feeCodeConfigEntity = new FeeCodeConfigEntity();
        feeCodeConfigEntity.setFeeCode(feeCode);
        feeCodeConfigEntity.setId(id);
        feeCodeConfigEntity  = (FeeCodeConfigEntity)dataJsonService.getByQueryKey(feeCodeConfigEntity);
        return JSON.toJSONString(feeCodeConfigEntity);
    }

}
